#include "bonecobrunomeira.h"

#include <GL/glu.h>
#include "gllib/Objects.h"

void BonecoBrunoMeira::draw() {

    glEnable(GL_COLOR_MATERIAL);
    glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);

    float mat_specular[] = {0.7, 0.7, 0.7, 1.0};
    float shininess = 20;

    glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
    glMaterialf(GL_FRONT, GL_SHININESS, shininess);

    glPushMatrix();
    glTranslatef(0,2,0);
    drawHat(0,3.2,0);
    drawHead(0,3,0);
    drawEyes(-0.2,3,0.47);
    drawEyes(0.2,3,0.47);
    drawNeck(0,2.2,0);
    drawBody(0,1.2,0);
    drawRArm(0.9,1.7,0);
    drawLArm(-0.9,1.7,0);
    drawRLeg(0.5,-0.7,0);
    drawLLeg(-0.5,-0.7,0);
    glPopMatrix();

    glDisable(GL_COLOR_MATERIAL);

}

void BonecoBrunoMeira::drawHat(float x,float y,float z){
    glPushMatrix();
    glColor3f(0,1,0);
    glTranslatef(x,y,z);
    glScalef(0.5,0.5,0.5);
    gllibCylinder(1.5,0.1,100);
    glPopMatrix();

    glPushMatrix();
    glColor3f(0,1,0);
    glTranslatef(x,y+0.25,z);
    glScalef(0.3,0.5,0.5);
    gllibCylinder(1.5,1,100);
    glPopMatrix();
}

void BonecoBrunoMeira::drawHead(float x,float y,float z){
    glPushMatrix();
    glColor3f(0,0,1);
    glTranslatef(x,y,z);
    glScalef(0.5,0.5,0.5);
    gllibSphere(1,100);
    glPopMatrix();
}

void BonecoBrunoMeira:: drawEyes(float x,float y,float z){
    glPushMatrix();
    glColor3f(1,1,1);
    glTranslatef(x,y,z);
    glScalef(1,1,0.1);
    glRotatef(90,1,0,0);
    gllibCylinder(0.05,0.1,100);
    glPopMatrix();
}

void BonecoBrunoMeira::drawNeck(float x,float y,float z){
    glPushMatrix();
    glColor3f(0,0,1);
    glTranslatef(x,y,z);
    glScalef(1.5,2,0.8);
    gllibCube(0.3);
    glPopMatrix();
}
void BonecoBrunoMeira::drawBody(float x,float y,float z){
    glPushMatrix();
    glColor3f(0,0,1);
    glTranslatef(x,y,z);
    glScalef(1.5,2,0.8);
    gllibCube(1);
    glPopMatrix();
}



void BonecoBrunoMeira::drawRArm(float x,float y,float z){
    glPushMatrix();
    glColor3f(0,0,1);
    glTranslatef(x+0.6,y,z+0.3);
    glRotatef(90,0,1,0);
    glScalef(3,1,1);
    gllibCube(0.3);
    glPopMatrix();

    glPushMatrix();
    glColor3f(0,0,1);
    glTranslatef(x,y,z);
    glScalef(3,1,1);
    glRotatef(90,0,0,1);
    gllibCube(0.3);
    glPopMatrix();
}

void BonecoBrunoMeira::drawLArm(float x,float y,float z){
    glPushMatrix();
    glColor3f(0,0,1);
    glTranslatef(x-0.6,y,z+0.3);
    glRotatef(90,0,1,0);
    glScalef(3,1,1);
    gllibCube(0.3);
    glPopMatrix();

    glPushMatrix();
    glColor3f(0,0,1);
    glTranslatef(x,y,z);
    glScalef(3,1,1);
    glRotatef(90,0,0,1);
    gllibCube(0.3);
    glPopMatrix();
}

void BonecoBrunoMeira::drawRLeg(float x,float y,float z){
    glPushMatrix();
    glColor3f(0,0,1);
    glTranslatef(x,y,z);
    glScalef(1,6,1.5);
    gllibCube(0.3);
    glPopMatrix();

    glPushMatrix();
    glColor3f(0,0,0);
    glTranslatef(x,y-1,z+0.1);
    glScalef(3,1,3.2);
    gllibCube(0.2);
    glPopMatrix();
}

void BonecoBrunoMeira::drawLLeg(float x,float y,float z){
    glPushMatrix();
    glColor3f(0,0,1);
    glTranslatef(x,y,z);
    glScalef(1,6,1.5);
    gllibCube(0.3);
    glPopMatrix();

    glPushMatrix();
    glColor3f(0,0,0);
    glTranslatef(x,y-1,z+0.1);
    glScalef(3,1,3.2);
    gllibCube(0.2);
    glPopMatrix();
}



